open(BUFF,"SNP.txt") or die "SNP.txt no found\n";
open(LOC,"snploc.txt") or die "snploc.txt not found\n";
$line = <BUFF>;
$line = <LOC>;
while(<BUFF>)
{
	chomp($_);
	$line = <LOC>;
	chomp($line);
	@loc = split("\t",$line);
	@array = split("\t",$_);
	$snp = shift(@array);
	$_ = join("\t",@array);
	$count1 =($_ =~ s/2/2/g);
	$count2 =($_ =~ s/1/1/g);
	$count3 =($_ =~ s/0/0/g);
	if($count1 >10 && $count2 >10 && $count3 >10 && $loc[1] <23)
	{
		#print $snp."\n";
		$hash{$snp} =1;
	}
}
open(BUFF,"./results_permutation/PVAL.txt") or die "PVAL.txt not found\n";
open(WRBUFF,">temp_test") or die "PVAL_removed_10_count not found\n";
$line = <BUFF>;
print WRBUFF $line;
@array = ();
while(<BUFF>)
{
        chomp($_);
        $_ =~ s/"//g;
        @array = split("\t",$_);
        if(exists($hash{$array[0]}))
        {
                print WRBUFF $_."\n";
        }
}

=head
open(BUFF,"new_PVAL.txt") or die "PVAL.txt not found\n";
open(WRBUFF,">PVAL_removed_10_count") or die "PVAL_removed_10_count not found\n";
$line = <BUFF>;
print WRBUFF $line;
@array = ();
while(<BUFF>)
{
        chomp($_);
        $_ =~ s/"//g;
        @array = split("\t",$_);
        if(exists($hash{$array[0]}))
        {
                print WRBUFF $_."\n";
        }
}

open(BUFF,"./results_permutation_PVAL_filtered/PVAL_980625693.txt") or die "PVAL.txt not found\n";
open(WRBUFF,">PVAL_removed_10_count_perm") or die "PVAL_removed_10_count not found\n";
$line = <BUFF>;
print WRBUFF $line;
@array = ();
while(<BUFF>)
{
        chomp($_);
	$_ =~ s/"//g;
	@array = split("\t",$_);
	if(exists($hash{$array[0]}))
	{
		print WRBUFF $_."\n";
	}	
}
